home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / TEMP / GNU / flex / Format < prev    next >
Text File  |  1995-06-28  |  3KB  |  109 lines

  1. Format
  2. Previous: <Examples=>Examples> * Next: <Patterns=>Patterns> * Up: <Top=>!Root>
  3.  
  4. #Wrap on
  5. {fH3}Format of the input file{f}
  6.  
  7. The {fCode}flex{f} input file consists of three sections, separated
  8. by a line with just {fEmphasis}%%{f} in it:
  9.  
  10. #Wrap off
  11. #fCode
  12. definitions
  13. %%
  14. rules
  15. %%
  16. user code
  17. #f
  18. #Wrap on
  19.  
  20. The {fUnderline}definitions{f} section contains declarations of simple
  21. {fUnderline}name{f} definitions to simplify the scanner specification,
  22. and declarations of {fUnderline}start conditions{f}, which are explained
  23. in a later section.
  24. Name definitions have the form:
  25.  
  26. #Wrap off
  27. #fCode
  28. name definition
  29. #f
  30. #Wrap on
  31.  
  32. The "name" is a word beginning with a letter or an
  33. underscore ('\_') followed by zero or more letters, digits, '\_',
  34. or '-' (dash).  The definition is taken to begin at the
  35. first non-white-space character following the name and
  36. continuing to the end of the line.  The definition can
  37. subsequently be referred to using "\{name\}", which will
  38. expand to "(definition)".  For example,
  39.  
  40. #Wrap off
  41. #fCode
  42. DIGIT    [0-9]
  43. ID       [a-z][a-z0-9]\*
  44. #f
  45. #Wrap on
  46.  
  47. defines "DIGIT" to be a regular expression which matches a
  48. single digit, and "ID" to be a regular expression which
  49. matches a letter followed by zero-or-more
  50. letters-or-digits.  A subsequent reference to
  51.  
  52. #Wrap off
  53. #fCode
  54. \{DIGIT\}+"."\{DIGIT\}\*
  55. #f
  56. #Wrap on
  57.  
  58. is identical to
  59.  
  60. #Wrap off
  61. #fCode
  62. ([0-9])+"."([0-9])\*
  63. #f
  64. #Wrap on
  65.  
  66. and matches one-or-more digits followed by a '.' followed
  67. by zero-or-more digits.
  68.  
  69. The {fStrong}rules{f} section of the {fCode}flex{f} input contains a series of
  70. rules of the form:
  71.  
  72. #Wrap off
  73. #fCode
  74. pattern   action
  75. #f
  76. #Wrap on
  77.  
  78. where the pattern must be unindented and the action must
  79. begin on the same line.
  80.  
  81. See below for a further description of patterns and
  82. actions.
  83.  
  84. Finally, the user code section is simply copied to
  85. {fCite}lex.yy.c{f} verbatim.  It is used for companion routines
  86. which call or are called by the scanner.  The presence of
  87. this section is optional; if it is missing, the second {fEmphasis}%%{f}
  88. in the input file may be skipped, too.
  89.  
  90. In the definitions and rules sections, any {fEmphasis}indented{f} text or
  91. text enclosed in {fEmphasis}%\{{f} and {fEmphasis}%\}{f} is copied verbatim to the
  92. output (with the {fEmphasis}%\{\}{f}'s removed).  The {fEmphasis}%\{\}{f}'s must
  93. appear unindented on lines by themselves.
  94.  
  95. In the rules section, any indented or %\{\} text appearing
  96. before the first rule may be used to declare variables
  97. which are local to the scanning routine and (after the
  98. declarations) code which is to be executed whenever the
  99. scanning routine is entered.  Other indented or %\{\} text
  100. in the rule section is still copied to the output, but its
  101. meaning is not well-defined and it may well cause
  102. compile-time errors (this feature is present for {fCode}POSIX{f} compliance;
  103. see below for other such features).
  104.  
  105. In the definitions section (but not in the rules section),
  106. an unindented comment (i.e., a line beginning with "\/\*")
  107. is also copied verbatim to the output up to the next "\*\/".
  108.  
  109.